package com.ccy.product.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

/**
 * @author coder_ccy
 * @date 2022/7/26 14:44
 */

@Configuration
public class GuliThreadPoolExcuter {


    // 硬编码  写死了

    @Bean
    public ThreadPoolExecutor GuliThreadPoolExecuter(GuliThreadPoolExecuterProperties properties){
        return new ThreadPoolExecutor(
                properties.getCorePoolSize(),
             properties.getMaxPoolSize(),
             properties.getKeepAliveTime(),
             TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(properties.getBlokingQueueLength()),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );

    }
}
